<?php

class Admin_Form_Register extends Zend_Form
{

    public function init()
    {
        $this->setMethod('post');
        $this->setAttrib('class', 'validate-form');
        
        
      	$this->addElement('select','cbbLocation',array(
      				'label'			=> 'Khu vực - mặc bằng thuê',
      				'require'		=> true,
      				'class'			=> 'required',
      				'multiOptions'	=> array($this->getAllLocationRent())
      			));
        
        //
        // PHAN CUA BANG KHACH
        $this->addElement('hidden','txtDescPer',array(
      										'description'=>"Thông tin về cá nhân/Tổ chức",
        									'class'	=> 'register-desc'
      			));
        $this->addElement('hidden','txtDescPer',array(
      										'description'=>"Thông tin về cá nhân/Tổ chức",
        									'class'	=> 'register-desc'
      			));
        $this->addElement('text','txtAgent',array(
        			'label'		=> 'Nguời đại diện: ',
        			'required'	=> TRUE,
        			'class'		=> 'required'
        		));
        $this->addElement('text','txtOffice',array(
        			'label'		=> 'Chức vụ: ',
        			'required'	=> TRUE,
        			'class'		=> 'required'
        		));
        $this->addElement('text','txtOrganization',array(
        			'label'		=> 'Tổ chức: ',
        			'required'	=> TRUE,
        			'class'		=> 'required'
        		));
        $this->addElement('text','txtAddress',array(
        			'label'		=> 'Địa chỉ: ',
        			'required'	=> TRUE,
        			'class'		=> 'required'
        		));
        $this->addElement('text','txtPhone',array(
        			'label'		=> 	'Điện thoại: ',
        			'required'	=> 	TRUE,
        			'class'		=> 	'required number',
        			'minlength'	=>	10,
        			'maxlength'	=>	15
        		));
        $this->addElement('text','txtEmail',array(
        			'label'		=> 'Email: ',
        			'required'	=> TRUE,
        			'class'		=> 'required email'
        		));
        $this->addElement('text','txtFax',array(
        			'label'		=> 'Fax: ',
        			'required'	=> TRUE,
        			'class'		=> 'required number'
        		));
        $this->addElement('text','txtNational',array(
        			'label'		=> 'Quốc gia: ',
        			'required'	=> TRUE,
        			'class'		=> 'required'
        		));
        //
        //PHAN CUA BANG DANG KY
      	$this->addElement('hidden','txtDescService',array(
      										'description'=>"Thông tin về dịch vụ đăng ký",
      										'class'	=> 'register-desc'
      			));
        $this->addElement('select','cbbMenu2',array(
        			'label'			=> 'Dịch vụ: ',
        			'required'		=> TRUE,
        			'multiOptions'	=> $this->getAllMenu2()	
        		));
        $this->addElement('text','txtDateExpect',array(
        			'label'			=> 'Ngày dự kiến: ',
        			'required'		=> TRUE,
        			'class'			=> 'required'
        		));
        $this->addElement('text','txtDateRent',array(
        			'label'			=> 'Thời gian thuê (năm): ',
        			'required'		=> TRUE,
        			'class'			=> 'required number',
        			'maxlength'		=> '3'
        		));
        $this->addElement('text','txtAreaRent',array(
        			'label'			=> 'Diện tích thuê (met vuông ): ',
        			'required'		=> TRUE,
        			'class'			=> 'required number',
        			'maxlength'		=> 10,
        			'minlength'		=> 2
        		));
        $this->addElement('textarea','txtPurposeRent',array(
        			'label'			=> 'Mục đích thuê : ',
        			'required'		=> TRUE,
        			'class'			=> 'required',
        			'cols'			=> 60,
        			'rows'			=> 10
        		));
    }
    
	/**
     * 
     * Set action cho form
     * @param unknown_type $actionName: ten cua action
     */
    function addAction($module,$controller, $actionName){
    	$this->setAction(Zend_Controller_Front::getInstance()->getBaseUrl()."/".$module."/".$controller."/".$actionName);
    }
    
    /**
     * 
     * Add nut submit 
     */
    function addSubmitButton($name, $label){
    	$this->addElement('submit',$name,array(
    						'label'		=>	$label,
    						'decorators'=>	array('ViewHelper',array('HtmlTag',array(
    																			'tag' => 'dd' //giu nguyen the dd ko them bat cu the j
    																		)
    														
    															)
    							
    										),
    						'class'		=>	'input-hover uSubmit'	
    					));
    	
    }
    
    function addHiddenId($name,$value){
    	$this->addElement('hidden',$name,array(
			    				'value'	=> $value	
    						));
    }
    

	private function getAllMenu2(){
    	$menu2 = new Admin_Model_Menu2();
    	$menu2 = $menu2->fetchAllMenu2('dangKyDV = 1');
    	$arrData = array();
    	foreach ($menu2 as $value) {
    		$arrData[$value['menu2Id']] =$value['tenMenu2']	;
    	}
    	return $arrData;
    }
    
	private function getAllLocationRent(){
    	$location = new Admin_Model_Locationrent();
    	$locationRent = $location->fetchAllLocationRent('trong = 0');
    	$arrData = array();
    	$arrData[0] = "Chọn khu vực - mặc bằng cần thuê";
    	foreach ($locationRent as $value) {
    		$arrData[$value['khuVucId']] =$value['khuVuc']	;
    	}
    	return $arrData;
    }


}

